package com.example.yangxu0703.thundermapclient.activity;

import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.TextView;

import com.example.yangxu0703.thundermapclient.R;

public class BaseActivity extends FragmentActivity {

    private TextView left, content, right;
    private View view;

    private void initTitleBar(){
        //view = getLayoutInflater().inflate(R.layout.title_layout, null, false);
        left = findViewById(R.id.left_icon);
        content =findViewById(R.id.title_word);
        right = findViewById(R.id.right_icon);
    }

    public void NoLeftIcon(String text, View.OnClickListener rightevent,int id) {
        initTitleBar();
        if (content != null) {
            content.setText(text);
        }
        if (right != null) {
            right.setBackgroundDrawable(getResources().getDrawable(id));
            right.setOnClickListener(rightevent);
        }
    }

    public void NoRightIcon(String text, View.OnClickListener leftevent,int id) {
        initTitleBar();
        if (content != null) {
            content.setText(text);
        }
        if (left != null) {
            left.setBackgroundDrawable(getResources().getDrawable(id));
            left.setOnClickListener(leftevent);
        }
    }

    public void setEvent(String text, View.OnClickListener leftevent, View.OnClickListener rightevent,int lid,int rid) {
        initTitleBar();
        if (content != null) {
            content.setText(text);
        }
        if (left != null) {
            left.setBackgroundDrawable(getResources().getDrawable(lid));
            left.setOnClickListener(leftevent);
        }
        if (right != null) {
            right.setBackgroundDrawable(getResources().getDrawable(rid));
            right.setOnClickListener(rightevent);
        }
    }

    public void  doubleNoIcon(String text){
        initTitleBar();
        content.setText(text);
    }

}
